package com.xzy.mapper;

import com.xzy.entity.Content;
import com.xzy.entity.Report;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value="ReportMapper")
public interface ReportMapper {

    @Insert("insert into report(userId,departmentId,reportTitle,status,uploadTime,reportDate) values (#{userId},#{departmentId},#{reportTitle},#{status},#{uploadTime},#{reportDate})")
    void addReport(Report report);

    @Select("select * from report")
    List<Report> getAllReport();

    @Select("select * from report where reportId=#{reportId}")
    Report getReport(int reportId);

    @Select("select * from report where reportTitle=#{reportTitle}")
    Report getReportByName(String reportTitle,String reportDate);

    @Update("update report set userId=#{userId},departmentId=#{departmentId},reportTitle=#{reportTitle},status=#{status},uploadTime=#{uploadTime},reportDate=#{reportDate} where reportId=#{reportId}")
    void updateReport(Report report);

    /*@Update("uplate content set serialNumber=#{serialNumber}，workContent=#{workContent},workProblem=#{workProblem},workMeasure=#{workMeasure},solveProblem=#{solveProblem} where contentId=#{contentId}")
    void updateContent(Report report);*/

    @Delete("delete from report where reportId=#{reportId}")
    void deleteReport(int reportId);

    @Select("select * from report where reportDate=#{reportDate}")
    List<Report> getReportByDate(String reportDate);

    @Select("select * from report where departmentId=#{departmentId} and reportDate=#{reportDate}")
    Report getReportByDepartmentAndDate(int departmentId,String reportDate);

   @Select("SELECT department.departmentId FROM department where department.departmentId not in (select departmentId from report where report.reportDate=#{reportDate})")
    List<Integer> getDepartmetByDate(String reportDate);



}
